//
//  ViewController.m
//  NhomMinhThuy
//
//  Created by admin on 5/9/15.
//  Copyright (c) 2015 Module4. All rights reserved.
//

#import "ViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()
            

@end

@implementation ViewController
            
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)clickPlayMp3:(id)sender {
    
    
    NSString *soundFilePath = [NSString stringWithFormat:@"%@/winning.mp3", [[NSBundle mainBundle] resourcePath]];
    NSString* path = [[NSBundle mainBundle] pathForResource:@"winning" ofType:@"mp3"];
    NSURL *soundFileURL = [NSURL fileURLWithPath:path];
    
    
    //CFURLRef
    SystemSoundID sound;
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)soundFileURL, &sound);
    AudioServicesPlaySystemSound(sound);
    
//    player.numberOfLoops = -1; //Infinite
//    [player setVolume:1.0];
//    [player prepareToPlay];
//    if ([player isPlaying]) {
//        [player pause];
//    } else {
//        [player play];
//    }
}

- (IBAction)clickPlayOgg:(id)sender {
    
//    NSString* path = [[NSBundle mainBundle] pathForResource:@"sticks" ofType:@"ogg"];
//    NSURL *soundFileURL = [NSURL fileURLWithPath:path];
//        //CFURLRef
//    SystemSoundID sound;
//    AudioServicesCreateSystemSoundID((__bridge CFURLRef)soundFileURL, &sound);
//    AudioServicesPlaySystemSound(sound);
    
}
@end
